package spark.sql.utils

/**
 * @Author Jeremy Zheng
 * @Date 2021/3/31 16:18
 * @Version 1.0
 * 将IP地址转为二进制，再转为十进制
 */
object IpTransform {
  def IpToLong(ip:String): Long = {
    val ips: Array[String] = ip.split("\\.")
    var ipNum:Long=0L
    for(i<-ips){
      ipNum=i.toLong | ipNum << 8L
    }
    ipNum
  }
}
